package com.bilin.coin.activity;

import android.view.View;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.bilin.coin.R;
import com.bilin.coin.bean.CoinBean;
import com.bilin.coin.common.base.BaseAppCompatActivity;
import com.bilin.coin.tools.Geter;

import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;
import butterknife.OnClick;


@Route(path = "/order/RechargeCoinActivity")
public class RechargeCoinActivity extends BaseAppCompatActivity {

    @BindView(R.id.tv_coin_address)
    TextView tv_coin_address;
    @BindView(R.id.tv_title_address)
    TextView tv_title_address;
    @BindView(R.id.tv_title_info)
    TextView tv_title_info;
    @BindView(R.id.tv_info1)
    TextView tv_info1;
    @BindView(R.id.tv_info2)
    TextView tv_info2;
    @BindView(R.id.tv_info3)
    TextView tv_info3;


    @Autowired
    CoinBean coinBean;

    @Override
    protected void initView() {
        setTitle("充"+coinBean.getName());
        setMenu("充"+coinBean.getName()+"纪录");
        tv_title_address.setText("充"+coinBean.getName()+"地址:");
        tv_title_info.setText("充"+coinBean.getName()+"须知：");
        tv_info1.setText("1.严禁充"+coinBean.getName()+"到"+coinBean.getName()+"之外的地址，任何充到非"+coinBean.getName()+"地址的资产将不可兑换。");
        tv_info2.setText("2."+coinBean.getName()+"的转入为自动转入，网络确认后自动到账，到账时间一般在5分钟-30分钟左右。");
        tv_info3.setText("3.该地址是您专用的转入地址，可以同时进行多种转入。");
        getAddress();
    }

    @Override
    public void setMenuOnClickListener() {
        jumpRecord();
    }

    private void jumpRecord() {
        baseStartActivityWith("/order/RechargeWithdrawCoinRecordActivity")
                .withInt("type", 0)
                .withParcelable("coinBean",coinBean)
                .navigation();
    }

    @Override
    protected void initData() {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_recharge_coin;
    }


    private void getAddress() {
        new Geter(this) {
            @Override
            protected String fillUrl() {
                return "/api/coin/getCoinAddress";
            }

            @Override
            protected Map<String, String> fillParams() {
                HashMap params = new HashMap();
                params.put("id",coinBean.getId()+"");
                return params;
            }

            @Override
            protected void disposeSuccess(String dataJson) {
                super.disposeSuccess(dataJson);
                tv_coin_address.setText(dataJson);
            }
        };
    }

    @OnClick({R.id.bt_confirm})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.bt_confirm:
                copeClipSuccess(tv_coin_address.getText().toString().trim());
                break;
        }
    }

}
